package org.hotDating.android.individual.mmi;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class Invitation extends Activity {

	GridView mGrid;

	private static final int ITEM_NUM = 5;
	private static final int ITEM_FRIENDS = 0;
	private static final int ITEM_PLACE = 1;
	private static final int ITEM_TIME = 2;
	private static final int ITEM_FEE = 3;
	private static final int ITEM_MASSAGE = 4;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.invitation);
		mGrid = (GridView) findViewById(R.id.invitationGrid);
		mGrid.setAdapter(new IconAdapter());
		OnItemClickListener clickedHandler = new OnItemClickListener() {
			public void onItemClick(AdapterView parent, View v, int position,
					long id) {
				Intent i = new Intent(Invitation.this, Invitation.class);
				switch (position) {
				case ITEM_FRIENDS:
					i = new Intent(Invitation.this, Friends.class);
					break;
				case ITEM_PLACE:
					break;
				case ITEM_TIME:
					break;
				case ITEM_FEE:
					break;
				case ITEM_MASSAGE:
					break;
				default:
					break;
				}
				startActivity(i);
			}
		};
		mGrid.setOnItemClickListener(clickedHandler);
	}

	public class IconAdapter extends BaseAdapter {

		private Integer[] mIconIds = { R.drawable.invitation_friends,
				R.drawable.invitation_place, R.drawable.invitation_time,
				R.drawable.invitation_fee, R.drawable.invitation_message };

		public IconAdapter() {
		}

		public View getView(int position, View convertView, ViewGroup parent) {
			ImageView i;

			if (convertView == null) {
				i = new ImageView(Invitation.this);
				i.setScaleType(ImageView.ScaleType.FIT_CENTER);
				i.setLayoutParams(new GridView.LayoutParams(50, 50));
			} else {
				i = (ImageView) convertView;
			}

			i.setImageResource(mIconIds[position]);

			return i;
		}

		public final int getCount() {
			return ITEM_NUM;
		}

		public final Object getItem(int position) {
			return position;
		}

		public final long getItemId(int position) {
			return position;
		}
	}
}
